package impl

type OptimizeStockTransactionRecordDaoImpl struct {
	*BaseDaoImpl
}

// 返回dao实现类
func GetOptimizeStockTransactionRecordDaoImpl() *OptimizeStockTransactionRecordDaoImpl {
	return &OptimizeStockTransactionRecordDaoImpl{GetBaseDaoImpl()}
}

// 返回表名
func (_optimizeStockTransactionRecordDaoImpl *OptimizeStockTransactionRecordDaoImpl) FindTableName() string {
	return "OPTIMIZE_ACCOUNT"
}

// 根据buy_date，删除sell_date为空的记录
func (_optimizeStockTransactionRecordDaoImpl *OptimizeStockTransactionRecordDaoImpl) DeleteBySellDateNullAndBuyDate(date string) {
	_optimizeStockTransactionRecordDaoImpl.db.Exec("delete optimize_stock_transact_record where buy_date=to_date(?,'yyyy-mm-dd') and sell_date is null", date)
}

// 根据sell_date，将sell_date、sell_price、sell_amount、profit_and_loss、profit_and_loss_rate、stamp_duty、registration_fee_when_sell、commission_when_sell字段改为null
func (_optimizeStockTransactionRecordDaoImpl *OptimizeStockTransactionRecordDaoImpl) UpdateNullBySellDate(date string) {
	_optimizeStockTransactionRecordDaoImpl.db.Exec("update optimize_stock_transact_record "+
		"set sell_date=null, sell_price=null, sell_amount=null, profit_and_loss=null, profit_and_loss_rate=null, stamp_duty=null, registration_fee_when_sell=null, commission_when_sell=null "+
		"where sell_date=to_date(?,'yyyy-mm-dd')", date)
}
